<!DOCTYPE html>
<html>

	<head lang="en">
		<title>骡窝日报</title>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
		<link rel="stylesheet" href="/js/bootstrap/css/bootstrap.min.css">
		<script src="/js/jquery/jquery.min.js"></script>
		<script src="/js/bootstrap/js/bootstrap.min.js"></script>
		<link rel="stylesheet" href="/css/font/css/font-awesome.min.css" />
		<link rel="stylesheet" href="/js/plugins/dialog/dialog.css" />
		<link rel="stylesheet" href="/css/reset.css" />
		<link rel="stylesheet" href="/css/news.css" />
		<script src="/js/plugins/jrender/jrender.js"></script>
		<script src="/js/common.js"></script>
		<script src="/js/plugins/dialog/dialog.min.js"></script>

		<script>
            $(function () {
                var currentPage = 1;//当前页
                var pages;//总页数
                var news;//日报数组
                function renderView(data) {
                    $(".news").renderValues(data,{
                        handle:function (ele, value) {
							ele.href="/newsContent.html?id="+value;
                        }
                    })
                }

                //发送ajax请求,获取所有发布的日报
                $.get("/news", {state: 2, pageSize: 5}, function (data) {
                    renderView(data);
                    pages = data.pages;
                    news = data.list;
                    goodId = data.goodId;

                    setTimeout(function () {
						// 检查用户是否点赞
                        checkAddGood(user, goodId);
                    }, 10);
                });

                //设置窗口滚动事件
                $(window).scroll(function () {
                    if (isEnd()) {
                        if (currentPage < pages) {
                            currentPage++;
                            $.get("/news", {state: 2, pageSize: 3, currentPage: currentPage}, function (data) {
                                var data = $.merge(news, data.list);
                                renderView({list: data});
                            })
                        } else {
                            $(document).dialog({
                                type: "notice",
                                infoText: "已经到底部了",
                                autoClose: 2500,
                                position: "bottom"  // center: 居中; bottom: 底部
                            });
                        }
                    }
                })
            });
		</script>

	</head>

	<body>
		

		<div class="search-head">
			<div class="row nav-search">
				<div class="col-2">
					<a href="index.html">
						<span><i class="fa fa-chevron-left fa-2x"></i></span>
					</a>
				</div>
				<div class="col-8">
					<div class="input-group-sm search">
						<input class="form-control searchBtn" placeholder="搜索资讯">
					</div>
				</div>
				<div class="col-2">
					<a href="index.html">
						<span><i class="fa fa-home fa-fw fa-2x"></i></span>
					</a>
				</div>
			</div>
		</div>

		<div class="container news">
		
			<div class="news">
				<h6 class="news-title">骡窝日报 </h6>
				<div class="row" render-loop="list">
					<div class="col-12">
						<a href="newsContent.html"  data-id="2" render-key="list.id" render-fun="handle">
							<img class="rounded" width="100%" height="200px"  render-src="list.coverUrl">
						</a>
						<div class="caption">
							<p>
								<i class="fa fa-heart-o" render-html="list.goods"></i>
							</p>
							<a href="newsContent.html" render-key="list.id" render-fun="handle">
							<p render-html="list.title"></p>
							</a>
						</div>
					</div>
				</div>
			</div>
		</div>

	

</body>
</html>